home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmigaPlus / Tools / Development / AmigaTalk / guibuilder / GenC.template < prev   
Encoding:
Text File  |  2004-01-31  |  7.1 KB  |  348 lines

  1. /****h* $ProjectFileName [$ProjectVersion] ****************
  2. *
  3. * NAME
  4. *    $ProjectFileName
  5. *
  6. * DESCRIPTION
  7. * SYNOPSIS 
  8. *    $ProjectName is a GUI for....
  9. *
  10. * HISTORY
  11. *    $DateToday - Created this file.
  12. *
  13. * COPYRIGHT
  14. *    $ProjectFileName $DateToday(C) by $ProjectAuthorName
  15. *
  16. * NOTES
  17. *
  18. *    $VER: $ProjectFileName $ProjectVersion ($DateToday) by $ProjectAuthorName
  19. ************************************************************************
  20. *
  21. */
  22.  
  23. #include <stdio.h>
  24. #include <string.h>
  25.  
  26. #include <exec/types.h>
  27.  
  28. #include <AmigaDOSErrs.h>
  29.  
  30. #include <intuition/intuition.h>
  31. #include <intuition/classes.h>
  32. #include <intuition/classusr.h>
  33. #include <intuition/imageclass.h>  // for Image Buttons only
  34. #include <intuition/gadgetclass.h>
  35.  
  36. #include <libraries/gadtools.h>
  37.  
  38. $ProgramOptionDefines
  39.  
  40. #ifdef $IconSupport
  41. # include <workbench/workbench.h>
  42. # include <workbench/startup.h>
  43. # include <workbench/icon.h>
  44. #endif
  45.  
  46. #ifdef $ASLSupport
  47. # include <utility/tagitem.h>
  48. # include <dos/dostags.h>
  49. # include <libraries/asl.h>
  50. #endif
  51.  
  52. #include <graphics/displayinfo.h>
  53. #include <graphics/gfxbase.h>
  54.  
  55. $IncludePragmas
  56.  
  57. #include <clib/exec_protos.h>
  58. #include <clib/intuition_protos.h>
  59. #include <clib/gadtools_protos.h>
  60. #include <clib/graphics_protos.h>
  61. #include <clib/utility_protos.h>
  62. #include <clib/diskfont_protos.h>
  63.  
  64. #include <proto/locale.h>
  65.  
  66. struct Catalog *catalog = NULL;
  67.  
  68. #define   CATCOMP_ARRAY    1
  69. $LocaleHeader
  70.  
  71. #define  MY_LANGUAGE "english"
  72.  
  73. $IncludeCommonFuncs
  74.  
  75. $GadgetIDs
  76.  
  77. // ----------------------------------------------------
  78.  
  79. #ifdef $ImageSupport
  80. IMPORT Class    *initGet( void ); // in Boopsi.o
  81.  
  82. struct IClass   *getClass = NULL;
  83. struct _Object  *getImage = NULL;
  84. #endif
  85.  
  86. #ifdef $IconSupport
  87.  
  88. IMPORT  struct WBStartup  *_WBenchMsg;
  89. PRIVATE struct DiskObject *diskobj = NULL;
  90.  
  91. struct Library *IconBase;
  92.  
  93. #endif
  94.  
  95. // ----------------------------------------------------
  96.  
  97. struct IntuitionBase *IntuitionBase;
  98. struct GfxBase       *GfxBase;
  99. struct Library       *GadToolsBase;
  100. struct LocaleBase    *LocaleBase;
  101.  
  102. // ----------------------------------------------------
  103.  
  104. PRIVATE char v[] = "\0$VER: $ProjectFileName $ProjectVersion " __AMIGADATE__ " by $ProjectAuthorName \0";
  105.  
  106. $GUIVariables
  107.  
  108. $MXStrings
  109. $CycleStrings
  110. $ListViewStrings
  111.  
  112. PRIVATE struct TextAttr $ScreenFontName$ScreenFontSize = { "$ScreenFontName.font", $ScreenFontSize, 0x00, 0x62 };
  113.  
  114. // TTTTTTTTT $ProjectFileName ToolTypes: TTTTTTTTT
  115.  
  116. #ifdef $IconSupport
  117.  
  118. PRIVATE char Tool1[32]     = "TOOL1";
  119.  
  120. PRIVATE char DefTool1[128] = "";
  121.  
  122. PRIVATE char *TTTool1      = &DefTool1[0];
  123.  
  124. #endif
  125.  
  126. // TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
  127.  
  128. #ifdef $ASLSupport
  129.  
  130. PRIVATE struct TagItem FileTags[] = {
  131.  
  132.    ASLFR_Window,          (ULONG) NULL,
  133.    ASLFR_TitleText,       (ULONG) "Obtain a filename...",
  134.    ASLFR_InitialHeight,   400,
  135.    ASLFR_InitialWidth,    500,
  136.    ASLFR_InitialTopEdge,  16,
  137.    ASLFR_InitialLeftEdge, 100,
  138.    ASLFR_PositiveText,    (ULONG) " OKAY! ",
  139.    ASLFR_NegativeText,    (ULONG) " CANCEL! ",
  140.    ASLFR_InitialPattern,  (ULONG) "#?",
  141.    ASLFR_InitialFile,     (ULONG) "",
  142.    ASLFR_InitialDrawer,   (ULONG) "RAM:",
  143.    ASLFR_Flags1,          FRF_DOPATTERNS,
  144.    ASLFR_Flags2,          FRF_REJECTICONS,
  145.    ASLFR_SleepWindow,     1,
  146.    ASLFR_PrivateIDCMP,    1,
  147.    TAG_END 
  148. };
  149.  
  150. #endif
  151.  
  152. $MenuFunctionNames
  153. $MenuArray
  154.  
  155. $IntuiTextArray
  156.  
  157. $GadgetTypesArray
  158. $GadgetFunctionNames
  159. $GadgetsArray
  160. $GadgetTagsArray
  161.  
  162. // ----------------------------------------------------
  163.  
  164. PRIVATE UBYTE em[512], *ErrMsg = &em[0];
  165.  
  166. /****i* CMsg() [$ProjectVersion] *************************************************
  167. *
  168. * NAME
  169. *    STRPTR rval = CMsg( int index, char *defaultStr );
  170. *
  171. * DESCRIPTION
  172. *    Obtain a string from the locale catalog file, failing that,
  173. *    return the default string.
  174. **********************************************************************
  175. *
  176. */
  177.  
  178. PRIVATE STRPTR CMsg( int strIndex, char *defaultString )
  179. {
  180.    if (catalog != NULL)
  181.       return( (STRPTR) GetCatalogStr( catalog, strIndex, defaultString ) );
  182.    else
  183.       return( (STRPTR) defaultString );
  184. }
  185.  
  186. /****i* SetupCatalog() [$ProjectVersion] *****************************************
  187. *
  188. * NAME
  189. *    SetupCatalog()
  190. *
  191. * DESCRIPTION
  192. **********************************************************************
  193. *
  194. */
  195.  
  196. PRIVATE void SetupCatalog( void )
  197. {
  198. $LocaleStrings
  199.    return;
  200. }
  201.  
  202. // ----------------------------------------------------------------
  203.  
  204. $SetupScreenCode
  205. $CloseScreenCode
  206. $CloseWindowCode
  207.  
  208. // ----------------------------------------------------------------
  209.  
  210. $MenuFunctions
  211. $GadgetFunctions
  212.  
  213. // ----------------------------------------------------------------
  214.  
  215. $BevelBoxRenderFunction
  216. $IntuiTextRenderFunction
  217. $OpenWindowDefn
  218. $IDCMPHandlers
  219. $IDCMPCode
  220.  
  221. // ----------------------------------------------------------------
  222.  
  223. PRIVATE void ShutdownProgram( void )
  224. {
  225. $CloseGUI 
  226.    if (catalog != NULL)
  227.       CloseCatalog( catalog );
  228.       
  229.    if (LocaleBase != NULL)
  230.       CloseLibrary( (struct Library *) LocaleBase );
  231.  
  232. #  ifdef $IconSupport
  233.    if (IconBase != NULL)
  234.       CloseLibrary( (struct Library *) IconBase );
  235. #  endif
  236.  
  237.    CloseLibs();
  238.    
  239.    return;
  240. }
  241.  
  242. PRIVATE int SetupProgram( void )
  243. {
  244.    int rval = RETURN_OK;
  245.    
  246.    if (OpenLibs() < 0)
  247.       {
  248.       rval = ERROR_INVALID_RESIDENT_LIBRARY;
  249.       
  250.       goto exitSetup;
  251.       }
  252.       
  253. #  ifdef $IconSupport
  254.    if ((IconBase = OpenLibrary( "icon.library", 37L )) == NULL)
  255.       {
  256.       fprintf( stderr, CMsg( MSG_FMT_LIB_UNOPENED, MSG_FMT_LIB_UNOPENED_STR ),
  257.                        "icon.library", "37" 
  258.              );
  259.  
  260.       ShutdownProgram();
  261.             
  262.       rval = ERROR_INVALID_RESIDENT_LIBRARY;
  263.       
  264.       goto exitSetup;
  265.       }
  266. #  endif
  267.  
  268.    if ((LocaleBase = OpenLibrary( "locale.library", 37L )) == NULL)
  269.       {
  270.       fprintf( stderr, CMsg( MSG_FMT_LIB_UNOPENED, MSG_FMT_LIB_UNOPENED_STR ),
  271.                        "locale.library", "37" 
  272.              );
  273.  
  274.       ShutdownProgram();
  275.             
  276.       rval = ERROR_INVALID_RESIDENT_LIBRARY;
  277.       
  278.       goto exitSetup;
  279.       }
  280.  
  281.    catalog = OpenCatalog( NULL, "$CatalogName",
  282.                                 OC_BuiltInLanguage, MY_LANGUAGE,
  283.                                 TAG_DONE 
  284.                         );
  285.  
  286.    (void) SetupCatalog();
  287.  
  288. $OpenGUI
  289. exitSetup:
  290.  
  291.    return( rval );
  292. }
  293.  
  294. #ifdef $IconSupport
  295. PRIVATE void *processToolTypes( char **toolptr )
  296. {
  297.    if (toolptr == NULL)
  298.       return( NULL );
  299.  
  300.    // Place your tool grabbers here:
  301.  
  302.    return( NULL );
  303. }
  304. #endif
  305.  
  306. PUBLIC int main( int argc, char **argv )
  307. {
  308. #  ifdef $IconSupport   
  309.    struct WBArg  *wbarg;
  310.    char         **toolptr = NULL;
  311. #  endif
  312.  
  313.    int error = RETURN_OK;
  314.  
  315.    if ((error = SetupProgram()) != RETURN_OK)
  316.       {
  317.       return( error );
  318.       }
  319.       
  320. #  ifdef $IconSupport   
  321.    if (argc > 0)    // from CLI:
  322.       {
  323.       // We prefer to use the ToolTypes: 
  324.       (void) FindIcon( &processToolTypes, diskobj, argv[0] );
  325.       }
  326.    else             // from Workbench:
  327.       {
  328.       wbarg   = &(_WBenchMsg->sm_ArgList[ _WBenchMsg->sm_NumArgs - 1 ]);
  329.       toolptr = FindTools( diskobj, wbarg->wa_Name, wbarg->wa_Lock );
  330.  
  331.       processToolTypes( toolptr );
  332.       }
  333. #  endif
  334.  
  335. $MainSettings
  336.  
  337. #  ifdef $IconSupport
  338.    FreeDiskObject( diskobj );
  339. #  endif
  340.    
  341.    ShutdownProgram();
  342.  
  343.    return( RETURN_OK );
  344. }
  345.  
  346. /* --------------- END of $ProjectFileName file! ------------------ */
  347.